﻿using Candy.Infrastructure;
using System;
using System.Windows;
using System.Windows.Controls;

namespace Candy
{
    public partial class ErrorInfoControl : UserControl, IErrorInfoControl
    {
        public ErrorInfoControl()
        {
            InitializeComponent();
        }

        private void OnClose(object sender, RoutedEventArgs e)
        {
            Close();
        }

        public string Title
        {
            get
            {
                return errotTitle.Text;
            }
            set
            {
                errotTitle.Text = value;
            }
        }

        private Exception _error;
        public Exception Error
        {
            get
            {
                return _error;
            }
            set
            {
                _error = value;
            }
        }

        public void Show()
        {
            Visibility = System.Windows.Visibility.Visible;
        }

        public void Show(Exception error, string title)
        {
            Title = title;
            Error = error;
            Show();
        }

        public void Close()
        {
            Visibility = System.Windows.Visibility.Collapsed;
        }

        private void OnShowError(object sender, RoutedEventArgs e)
        {
           
            ErrorWindow errWin = new ErrorWindow();
            errWin.Exception = Error;
            errWin.Show();

        }
    }
}
